package org.example.scenicspot.persistence;

import org.apache.ibatis.annotations.*;
import org.example.scenicspot.domain.EmergencyRescuePerson;
import org.example.scenicspot.domain.EmergencyRescueVehicle;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper

public interface emergencyRescuePersonMapper {
    @Select("select * from emergencyrescuepersonmsg")
    List<EmergencyRescuePerson> selectAll();

    @Select("SELECT * FROM emergencyrescuepersonmsg WHERE emergencyrescuepersonmsg.name LIKE CONCAT('%', #{name}, '%')")
    List<EmergencyRescuePerson> selectByName(@Param("name") String name);

    @Select("SELECT * FROM emergencyrescuepersonmsg WHERE ScenicAreaID = #{ScenicAreaID}")
    List<EmergencyRescuePerson> selectByScenicAreaID(int ScenicAreaID);

    @Delete("DELETE FROM emergencyrescuepersonmsg WHERE emergencyrescuepersonmsg.id = #{id}")
    int deleteById(@Param("id") int id);

    @Insert("INSERT INTO emergencyrescuepersonmsg (id,name,Qualification,ContactInfo,ScenicAreaID) VALUES (#{id},#{name}, #{Qualification}, #{ContactInfo}, #{ScenicAreaID})")
    void insert(int id, String name, String Qualification, String ContactInfo, int ScenicAreaID);

    @Update("UPDATE emergencyrescuepersonmsg SET name = #{name}, Qualification = #{Qualification}, ContactInfo = #{ContactInfo}, " +
            "ScenicAreaID = #{ScenicAreaID} WHERE id = #{id}")
    void update(int id, String name, String Qualification, String ContactInfo, int ScenicAreaID);
}
